﻿using Polymorphism.Extensions;

var numbers = new List<int> { 1, -2, 3, -4, 5, -6, 7, 8, 9, 10 };
bool shallAddPositiveOnly = true;

var multilineText = @"aaa
bbb
ccc
ddd";
Console.WriteLine("Count of lines is:" + multilineText.CountLines());
Console.WriteLine("Count of lines is:"+ StringExtensions.CountLines(multilineText));





NumbersSumCalculator calculator =
    shallAddPositiveOnly ? 
        new PositiveNumbersSumCalculator() : 
        new NumbersSumCalculator();

var sum = calculator.Calculate(numbers);
Console.WriteLine($"Sum is :{sum}");
Console.ReadKey();



public abstract class Dessert
{
}

public class Panettone : Dessert
{
    
}



public class NumbersSumCalculator
{
    public int Calculate(List<int> numbers)
    {
        int sum = 0;
        foreach (var number in numbers)
        {
            if (ShallBeAdded(number))
            {
                sum += number;    
            }
        }

        return sum;
    }

    protected virtual bool ShallBeAdded(int number)
    {
        return true;
    }
}

public class PositiveNumbersSumCalculator:NumbersSumCalculator
{
    protected override bool ShallBeAdded(int number)
    {
        return number > 0;
    }
    
}

public enum Season
{
    Spring,
    Summer,
    Automn,
    Winter
}